Ember.RadioButton = Ember.View.extend({

	classNames : [ 'ember-radio-button' ],

	defaultTemplate : Ember.Handlebars
		.compile(			
			'<input type="radio" ' + 
				'{{ bindAttr id="uid" name="group" checked="isChecked"  disabled="view.vDisabled" readonly="view.vReadonly" }} />' + 
			'{{#if view.showLabel}}' + 
				'<label class="choice" {{bindAttr for="uid"}}>' + 
					'{{label}}' + 
				'</label>' + 
			'{{/if}}'),

	bindingChanged: function(){
		var input = this.$('input:radio');	
		var context = Ember.get(this, 'context');
		if(input.attr('id') == Ember.get(this, 'value')){
			input.attr("checked", true);
			context.set('isChecked', true);
		} else {
			input.attr("checked", false);
			context.set('isChecked', false);
		}
//		console.log('=====================');
//		Vari.formFields[2].get('options').forEach(function(to) {
//			console.log(to.get('htmlId') +  ' = ' + to.get('isChecked'));
//		});
	}.observes("value"),

	change : function() {
		Ember.run.once(this, this._updateElementValue);
	},

	_updateElementValue : function() {
		var input = this.$('input:radio');
		Ember.set(this, 'value', input.attr('id'));
	}
});

App.Checkboxes = Ember.View.extend({
	classNames : [ 'ember-check-box' ],

	defaultTemplate : Ember.Handlebars
		.compile(			
			'<input type="checkbox" ' + 
				'{{ bindAttr id="uid" name="group" value="label" checked="isChecked" disabled="view.vDisabled" readonly="view.vReadonly" }} />' + 
			'{{#if view.showLabel}}' + 
				'<label class="choice" {{bindAttr for="uid"}}>' + 
					'{{label}}' + 
				'</label>' + 
			'{{/if}}')
});
